# 注意，由于各模块代码基于项目根目录，故应当在项目根目录下运行此脚本（项目根目录即此main.py文件所在目录）

from raw.train import main as raw_main
from attack.select_candidates import main as attack_select
from attack.generate import main as attack_main
from defense.defend import main as defense_main
from evaluation.attack_evaluation import main as attack_evaluate
from evaluation.defense_evaluation import main as defense_evaluate
from evaluation.security_evaluation import main as security_evaluate
from attack_config import attack_config
from defense_config import defense_config

model_name = 'MNIST'
attack_name = 'FGSM'
defense_name = 'NAT'

print('\n------------RAW------------\n')
raw_main(model_name)

print('\n------------ATTACK_SELECT------------\n')
attack_select(model_name)

print('\n------------ATTACK------------\n')
attack_main(model_name, attack_name, attack_config[attack_name])

print('\n------------DEFENSE------------\n')
defense_main(model_name, defense_name, defense_config[defense_name])

print('\n------------ATTACK_EVALUATION------------\n')
attack_evaluate(model_name, attack_name, attack_config[attack_name])

defense_config['RC']['search'] = False
defense_config['EAT']['train_externals'] = False
print('\n------------DEFENSE_EVALUATION------------\n')
defense_evaluate(model_name, defense_name, defense_config[defense_name])

print('\n------------SECURITY_EVALUATION------------\n')
security_evaluate(model_name, attack_name, [defense_name], attack_config[attack_name], [defense_config[defense_name]])
